﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>config_file_first_kind</title>
    <script src="~/lib/qs/qs.js"></script>
    <script src="~/lib/axios/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-header>
                <el-card class="box-card">
                    <el-col :span="2"> I级机构管理 </el-col><el-col :span="6" :offset="20"> 创建和维护I级机构 </el-col>
                </el-card>
            </el-header>
            <el-main>
                <el-card class="box-card">
                    <el-button type="primary"
                               @@click="dialogVisibleinsert = true"
                               style="float: right; margin-bottom: 20px;"
                               >添加</el-button>
                    <el-table :data="list1" style="width: 100%" border stripe>
                        <el-table-column prop="first_kind_id"
                                         label="I级机构编号"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="first_kind_name"
                                         label="I级机构名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="first_kind_salary_id"
                                         label="薪酬发放责任人编号"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="first_kind_sale_id"
                                         label="销售责任人编号"
                                         align="center">
                        </el-table-column>
                        <el-table-column label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button size="mini" type="primary" @@click="cz(scope.row)">编辑</el-button>
                                <el-button size="mini" type="danger" @@click="delt(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <el-row>
                        <el-col :span="1">
                            <el-pagination v-on:size-change="handleSizeChange"
                                           v-on:current-change="handleCurrentChange"
                                           :current-page="queryinfo.currentPage"
                                           :page-sizes="[1, 2, 3, 4]"
                                           :page-size="queryinfo.pageSize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="total">
                            </el-pagination>
                        </el-col>
                    </el-row>
                </el-card>
            </el-main>
        </el-container>
        <el-dialog title="I级机构修改"
                   :visible.sync="dialogVisibleUpdate"
                   width="50%">
            <el-form ref="formUpdate"
                     :model="formUpdate"
                     :rules="formruleUpdate"
                     label-width="97px">
                <el-form-item label="I级机构编号" prop="first_kind_id">
                    <el-input v-model="formUpdate.first_kind_id" style="width: 480px"></el-input>
                </el-form-item>
                <el-form-item label="I级机构名称" prop="first_kind_name">
                    <el-input v-model="formUpdate.first_kind_name" style="width: 480px"></el-input>
                </el-form-item>
                <el-form-item label="薪酬发放责任人编号" prop="first_kind_salary_id" label-width="149px">
                    <el-input v-model="formUpdate.first_kind_salary_id" style="width: 428px"></el-input>
                </el-form-item>
                <el-form-item label="销售责任人编号" prop="first_kind_sale_id" label-width="121px">
                    <el-input v-model="formUpdate.first_kind_sale_id" style="width: 456px"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @@click="dialogVisibleUpdate = false">取 消</el-button>
                <el-button type="primary" @@click="upda('formUpdate')">确 定</el-button>
            </span>
        </el-dialog>

        <el-dialog title="I级机构添加"
                   :visible.sync="dialogVisibleinsert"
                   width="50%">
            <el-form ref="forminsert"
                     :model="forminsert"
                     :rules="formruleinsert"
                     label-width="97px">
                <el-form-item label="I级机构编号" prop="first_kind_id">
                    <el-input v-model="forminsert.first_kind_id" style="width: 480px"></el-input>
                </el-form-item>
                <el-form-item label="I级机构名称" prop="first_kind_name">
                    <el-input v-model="forminsert.first_kind_name" style="width: 480px"></el-input>
                </el-form-item>
                <el-form-item label="薪酬发放责任人编号" prop="first_kind_salary_id" label-width="149px">
                    <el-input v-model="forminsert.first_kind_salary_id" style="width: 428px"></el-input>
                </el-form-item>
                <el-form-item label="销售责任人编号" prop="first_kind_sale_id" label-width="121px">
                    <el-input v-model="forminsert.first_kind_sale_id" style="width: 456px"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @@click="dialogVisibleinsert = false">取 消</el-button>
                <el-button type="primary" @@click="insert('forminsert')">确 定</el-button>
            </span>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                dialogVisibleUpdate: false,
                dialogVisibleinsert: false,
                list1: [],
                queryinfo: {
                    currentPage: 1,
                    pageSize: 3
                },
                total: 1,
                formUpdate: {
                    ffk_id: "",
                    first_kind_id: "",
                    first_kind_name: "",
                    first_kind_salary_id: "",
                    first_kind_sale_id: "",
                },
                formruleUpdate: {
                    first_kind_id: [
                        { required: true, message: '请输入I级机构编号', trigger: 'blur' }
                    ],
                    first_kind_name: [
                        { required: true, message: '请输入I级机构编号', trigger: 'blur' }
                    ],
                    first_kind_salary_id: [
                        { required: true, message: '请输入薪酬发放责任人编号', trigger: 'blur' }
                    ],
                    first_kind_sale_id: [
                        { required: true, message: '请输入销售责任人编号', trigger: 'blur' }
                    ],
                },
                forminsert: {
                    first_kind_id: "",
                    first_kind_name: "",
                    first_kind_salary_id: "",
                    first_kind_sale_id: "",
                },
                formruleinsert: {
                    first_kind_id: [
                        { required: true, message: '请输入I级机构编号', trigger: 'blur' }
                    ],
                    first_kind_name: [
                        { required: true, message: '请输入I级机构编号', trigger: 'blur' }
                    ],
                    first_kind_salary_id: [
                        { required: true, message: '请输入薪酬发放责任人编号', trigger: 'blur' }
                    ],
                    first_kind_sale_id: [
                        { required: true, message: '请输入销售责任人编号', trigger: 'blur' }
                    ],
                }
            },
            methods: {
                delt(row) {
                    this.$confirm('此操作将删除信息, 是否删除?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios.get('/config_file_first_kind/delt', {
                            params: {
                                ffk_id: row.ffk_id,
                            }
                        })
                            .then(res => {
                                console.info(res);
                                this.$message({
                                    message: "删除成功",
                                    type: "success",
                                });
                                this.fill();
                            })
                            .catch(err => {
                                console.info(err);
                            })
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },
                upda(formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将修改信息, 是否修改?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                axios.get('/config_file_first_kind/Updat', {
                                    params: {
                                        ffk_id: this.formUpdate.ffk_id,
                                        first_kind_id: this.formUpdate.first_kind_id,
                                        first_kind_name: this.formUpdate.first_kind_name,
                                        first_kind_salary_id: this.formUpdate.first_kind_salary_id,
                                        first_kind_sale_id: this.formUpdate.first_kind_sale_id
                                    }
                                })
                                    .then(res => {
                                        console.info(res);
                                        this.$message({
                                            message: "修改成功",
                                            type: "success",
                                        });
                                        this.fill();
                                        this.dialogVisibleUpdate = false;
                                    })
                                    .catch(err => {
                                        console.info(err);
                                    })
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消修改'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                insert(formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将添加信息, 是否添加?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                var qs = Qs;
                                axios.post('/config_file_first_kind/Inser',
                                    qs.stringify(
                                        this.forminsert
                                    ))
                                    .then(res => {
                                        console.info(res);
                                        this.$message({
                                            message: "添加成功",
                                            type: "success",
                                        });
                                        this.fill();
                                        this.dialogVisibleinsert = false;
                                    })
                                    .catch(err => {
                                        console.info(err);
                                    })
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消添加'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                cz(row) {
                    this.formUpdate.first_kind_id = row.first_kind_id;
                    this.formUpdate.first_kind_name = row.first_kind_name;
                    this.formUpdate.first_kind_salary_id = row.first_kind_salary_id;
                    this.formUpdate.first_kind_sale_id = row.first_kind_sale_id;
                    this.formUpdate.ffk_id = row.ffk_id;
                    this.dialogVisibleUpdate = true;
                },
                fill() {
                    axios.get('/config_file_first_kind/Index3', {
                        params: {
                            currentPage: this.queryinfo.currentPage,
                            pageSize: this.queryinfo.pageSize
                        }
                    })
                        .then(res => {
                            console.info(res);
                            this.list1 = res.data.Data;
                            this.total = res.data.Row;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                handleSizeChange(val) {
                    this.queryinfo.pageSize = val;
                    this.fill();
                },
                handleCurrentChange(val) {
                    this.queryinfo.currentPage = val;
                    this.fill();
                }
            },
            created: function () {
                this.fill();
            }
        });
    </script>
    <style scoped>
        .el-col-2 {
            width: 8.33333%;
            font-size: 15px;
            font-weight: 900;
            line-height: 0px;
        }

        .el-col-6 {
            width: 37.5%;
            font-size: 1px;
            font-weight: 300;
            color: rgb(83, 83, 83);
            line-height: 0px;
        }

        element.style {
            height: 100%;
            width: 1239px;
        }
        .el-card__body {
            padding: 35px;
        }
        .el-button.is-circle {
            border-radius: 50%;
            padding: 12px;
            position: relative;
            top: -10px;
            right: -570px;
        }
    </style>
</body>
</html>
